﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using Streaming_Service.Crawler;
using Streaming_Service.Media;
using Streaming_Service.User;

namespace Streaming_Service {
    using System.Collections;
    using System.IO;

    using Streaming_Service.Enum;
    using Streaming_Service.FileTransfer;

    [ServiceContract]
    public interface IRentIt {
        #region "User Stuff"
        [OperationContract] // Documented
        UserSession Login(string email, string password);

        [OperationContract]
        void Logout(UserSession session);

        [OperationContract] // Documented
        UserReturnCode CreateAccount(string name, string password, string email, DateTime birthday);

        [OperationContract] // Documented
        UserReturnCode UpdateAccount(UserSession user, string newPassword, string newEmail,
                           DateTime? newBirthday);

        [OperationContract] // Documented
        UserReturnCode DeleteAccount(UserSession user, string password);

        [OperationContract] // Documented
        UserReturnCode AdminUpdateAccount(UserSession admin, int userId, string newPassword, string newEmail,
                                DateTime? newBirthday, XBool isAdmin);

        [OperationContract] // Documented
        UserReturnCode AdminDeleteAccount(UserSession admin, int userId);

        [OperationContract]
        List<UserEntry> ListUsers();

        [OperationContract]
        List<UserEntry> ListOnlineUsers(int inactivityCutOff);

        [OperationContract]
        UserEntry GetUserInfo(int userId);

        [OperationContract]
        UserEntry GetUserInfoByEmail(string email);

        [OperationContract]
        string GetActivationCode(int userId);

        [OperationContract]
        bool ActivateAccount(int userId, string code);

        [OperationContract]
        bool IsAccountActivated(int userId);

        [OperationContract]
        List<MovieSearchEntry> ListAllSearches(int userid, int numResults);

        #endregion

        #region "Rating Stuff"
        [OperationContract]
        bool RateMovie(UserSession user, RatingEntry rating);

        [OperationContract]
        bool EditRating(UserSession user, RatingEntry rating);

        [OperationContract]
        bool DeleteRating(UserSession user, int movieId);

        [OperationContract]
        List<RatingEntry> ListRatings();

        [OperationContract]
        List<RatingEntry> ListUserRatings(int userId);

        [OperationContract]
        List<RatingEntry> ListMovieRatings(int movieId);
        #endregion

        #region "Movie Stuff"
        [OperationContract]
        bool Rent(int movieId, UserSession user, bool hd);

        [OperationContract]
        bool ActiveRent(int movieId, UserSession user, bool hd);

        [OperationContract]
        List<MovieEntry> SearchMovies(MovieSearchEntry searchEntry);

        [OperationContract]
        int InsertMovie(UserSession admin, MovieEntry movieEntry);

        [OperationContract]
        bool EditMovie(UserSession admin, int movieId, MovieEntry movieEntry);

        [OperationContract]
        bool DeleteMovie(UserSession admin, int movieId);

        [OperationContract]
        UploadFileResponse UploadMovieFile(UploadFileInfo uploadFileInfo);

        [OperationContract]
        UploadFileResponse UploadMovieThumb(UploadFileInfo uploadFileInfo);

        [OperationContract]
        HashSet<string> AllowedMovieFileExtensions();

        [OperationContract]
        HashSet<string> AllowedThumbFileExtensions();
            
        [OperationContract]
        MovieEntry MovieInfo(int movieId);

        [OperationContract]
        List<MovieEntry> ListMovies();

        [OperationContract]
        List<String> ListMovieLanguages();

        [OperationContract]
        int MovieCount();
        
        [OperationContract]
        bool AddGenre(UserSession admin, string genre);

        [OperationContract]
        bool GenreExists(string genre);

        [OperationContract]
        bool RemoveGenre(UserSession admin, int genreId);

        [OperationContract]
        bool RenameGenre(UserSession admin, int genreId, string newName);

        [OperationContract]
        bool AddMovieGenre(UserSession admin, int movieId, int genreId);

        [OperationContract]
        bool RemoveMovieGenre(UserSession admin, int movieId, int genreId);

        [OperationContract]
        List<GenreEntry> ListGenres();

        [OperationContract]
        ImdbMovieEntry GetImdbMovie(string imdbId);

        [OperationContract]
        bool MovieExists(string title, int year);

        [OperationContract]
        bool MovieExistsImdb(string imdbId);
        #endregion

        #region "Pricing Stuff"

        [OperationContract]
        decimal GetSdPrice(MovieEntry movie);

        [OperationContract]
        decimal GetHdPrice(MovieEntry movie);

        [OperationContract]
        decimal GetSdPriceByMovieId(int movieId);

        [OperationContract]
        decimal GetHdPriceByMovieId(int movieId);

        #endregion

        #region "Helper Stuff"

        [OperationContract]
        ParentalGuidance GetParentalGuidance(string toParse);

        [OperationContract]
        bool IsTrue(XBool xbool);

        #endregion

        #region "Rent Stuff"

        [OperationContract]
        List<RentSession> UserRents(int userId, bool onlyActive);

        [OperationContract]
        List<RentSession> UserRentSessions(UserSession user, bool onlyActive);

        #endregion
    }
}